
using System;
using System.Collections.Generic;
using aspnetcore.Models;
using System.Linq;

namespace aspnetcore.Repositories
{
    public class SysConfigRepository : ISysConfigRepository
    {
        private readonly HSContext _hsContext;

        public SysConfigRepository(HSContext hsContext) {
            _hsContext = hsContext;
        }

        public void Add(SysConfig model)
        {
            if (string.IsNullOrEmpty(model.Name) || string.IsNullOrEmpty(model.Val)) {
                throw new Exception("信息不完整");
            }

            _hsContext.SysConfig.Add(model);
            _hsContext.SaveChanges();
        }

        public IEnumerable<SysConfig> getAll()
        {
            return _hsContext.SysConfig.ToList();
        }
    }
}